var app=getApp();
//滑动滑动
var startX;
var startY;
var endX;
var endY;
var key;

Page({
	data: {
		xueqi: '',
        index:0,
        xueqixueqi:''
	},
    start:function(e){
        var touch=e.touches[0];
        startX= touch.clientX;
        startY =touch.clientY;
        key=true;
    },
    move:function(e){
        var that=this
        if(key){
            var touch =e.touches[0];
            endX = touch.clientX;
            endY = touch.clientY;
            var MoveNum=endX-startX;
            console.log(MoveNum)
                if(MoveNum<-6){
                    console.log('左划')
                    var page=that.data.index+1;
                    var XUEQI=that.data.xueqi[page];
                    that.setData({
						index: page,
                        xueqixueqi:XUEQI
					})
                }
            }if(MoveNum>6){
                console.log('右滑')
                var page=that.data.index-1;
                var XUEQI=that.data.xueqi[page];
                that.setData({
					index: page,
                    xueqixueqi:XUEQI
				})
            }
            key=false;
        
    },

	onLoad(){
		const _this = this;
		  app.getUserInfo(function(res){
				//console.log(res);
        var openId=res;
				wx.request({
                    // url: 'http://xiao.aviouy.cn/gis/api_chengji.php?openid='+openId, 
					url: 'http://www.zz-bin.cn/gis/api_chengji.php', 
					header: {
								'content-type': 'application/json'
						},
					success: function(res) {
								/*
                                console.log(res.data.error)
								var error=res.data.error;
								if(error==1){
									wx.showModal({
                                        content: '未完成评教,请前往教务系统评教',
                                        showCancel: false,
                                        success: function (res) {
                                            if (res.confirm) {
                                                console.log('用户点击确定,返回主页面')
                                                wx.navigateBack({
                                                  delta:1
                                                })
                                            }
                                        }
                                    });
								}	
                                if(error==2){
									wx.showModal({
                                        content: '学号或者密码错误请重新绑定',
                                        showCancel: false,
                                        success: function (res) {
                                            if (res.confirm) {
                                                console.log('用户点击确定,去到绑定页面')
            									wx.navigateTo({
                                                    url: '../regist/regist'
                                                })
                                            }
                                        }
                                    });
								}	
                                if(error==3){
									wx.showModal({
                                        content: '系统繁忙',
                                        showCancel: false,
                                        success: function (res) {
                                            if (res.confirm) {
                                                console.log('用户点击确定,主页面')
                                                wx.navigateBack({
                                                  delta:1
                                                })
                                            }
                                        }
                                    });
                                }
                                */
								// }else{
								// 		wx.showModal({
                //             content: '未知错误',
                //             showCancel: false,
                //             success: function (res) {
                //                 if (res.confirm) {
                //                     console.log('用户点击确定,主页面')
								// 										//  wx.navigateTo({
                //                     //     url: '../regist/regist'
                //                     // })
                //                 }
                //             }
                //     });
								// }
                               
							_this.setData({
								xueqi: res.data,
                                xueqixueqi:res.data[0]
								//loading: false
							})
                            console.log(_this.data.xueqixueqi)
                             
		  		}
				})
		})
	}
})